<template>
  <div class="main">
    <eagle-form
      ref="eagleForm"
      :model="form"
      @submitForm="onSubmit"
    >
      <eagle-input
        class="input_text"
        label="证书名称"
        required
        v-model="form.CertName"
      />
      <eagle-input
        class="input_text"
        label="证书编号"
        required
        v-model="form.CertCode"
      />
      <eagle-date
        label="有效期"
        :date.sync="form.NextReviewDate"
        showFastSelect="true"
      >
      </eagle-date>
      <eagle-file-upload
        @CallBack="_fileUploadCb"
        :attachs="form.Attach"
        :labelName="'证书附件'"
      />
      <div class="btn_submit">
        <eagle-button
          block
          type="info"
        > 提交 </eagle-button>
      </div>
    </eagle-form>

  </div>
</template>

<script>
import store from "@/store/index";

export default {
  data() {
    return {
      showCalendar: false,
      // form: {
      //   CertName: "",
      //   CertCode: "",
      //   NextReviewDate: "",
      //   Attach: "",
      //   ID: 0,
      // },
      form: {},
      border: false,
    };
  },
  created() {
    // this.form.ID = this.$route.query.id;
    this.calcTitle();
    this.getDetail();
  },
  computed: {},
  methods: {
    _fileUploadCb(attachs) {
      this.form.Attach = attachs;
    },
    getDetail() {
      let params = { id: this.$route.query.id };
      if (this.$route.query.id > 0) {
        _this.$axios
          .get("/ConstructSafeUserCert/GetDetail",{params:params})
          .then((res) => {
            this.form = res.data;
          });
      }
    },

    // handleShow(name) {
    //   this.showCalendar = true;
    //   this.selectKey = name;
    // },
    // onConfirm(date) {
    // 		const dateTime = formatDate(date)
    // 		this.form[this.selectKey] = getDate(dateTime)
    // 		this.showCalendar = false
    // 	},
    // 附件详情
    _goEnclosure(item) {
      // console.log(item,'sdvfdvdcd')
      this.$router.push({
        path: "/Credential/Enclosure",
        query: { attCode: item.AttCode },
      });
    },
    onSubmit() {
      let _this = this;
      _this.$axios
      .get("/ConstructSafeUserCert/Save",{params:_this.form})
      .then((res) => {
        if (res.success) {
          setTimeout(() => {
            _this.$toast.success("保存成功！");
          }, 300);
          _this.$router.goRefresh(-1);
        }
      });
    },
    calcTitle() {
      let id = this.$route.query.id;
      let title = "";
      if (id > 0) {
        title = "证书[编辑]";
      } else {
        title = "证书[新增]";
      }
      store.commit("updateTitle", title);
    },
  },
};
</script>

<style lang="less">
.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_riskunit_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 20px;
      width: 20px;
      margin-right: 5px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}
.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}

.text_box {
  padding: 10px;
  border-radius: 5px;
  /*background-color: #e8f1f8;*/
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_det {
  background-color: #fff;
  padding: 10px;
  .operate_list {
    border: 1px solid #e8f1f8;
    .operate_row_first {
      padding: 10px;
      background-color: #e8f1f8;
      border-bottom: 1px solid #e8f1f8;
      margin-bottom: 10px;
    }
    .operate_row {
      padding: 10px;
      border-bottom: 1px solid #e8f1f8;
      /*margin-bottom: 10px;*/
    }
  }
}
</style>
